import requests
import base64
import os
import json

main_api = 'http://127.0.0.1:36677/upload'

def getFile(img=None):

    if img == None:
        return
    
    return json.dumps({
        'list':[
            img
        ]
    })


def getUrl(img=None):


    if img == None:
        req = requests.post(url = main_api)
        data_url = req.json()['result'][0]
        return data_url
    
    data = getFile(img)

    req = requests.post(url = main_api, data=data)

    data_url = req.json()['result'][0]

    return data_url
